﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SDT.DataService.Contexts;
using SDT.Libraries.Utilities;
using SDT.DataService.Repositories;

namespace SDT.DataService.Services
{
    public class ErrorNewsService : IService<ErrorArticle>
    {
       #region Field
      
        private IRepository<ErrorArticle> repository;
        
        #endregion

        #region Constructor
        public ErrorNewsService()
            : this(new Repository<ErrorArticle>())
        {
        }

        public ErrorNewsService(IRepository<ErrorArticle> repository)
        {
            this.repository = repository;
          
        }
        #endregion

        #region Store Procedure  
        public int WC_ErrorNewsInsert(int ChannelId, int PageId, int CateSpiderID, DateTime CreatedDate, DateTime ModifyDate, string Title, string Lead, string Content, string OriginalUrl, string ImageDesc, byte status, bool errorTitle, bool errorSummary, bool errorContent, bool errorDateTime)
        {
            ErrorNewsContext contextObj = new ErrorNewsContext();

            try
            {
                int insertedValue = contextObj.sp_WC_ErrorArticle_Insert((int)ChannelId, (int)PageId, (int)CateSpiderID, CreatedDate, ModifyDate, Title, Lead, Content, OriginalUrl, ImageDesc, status, errorTitle, errorSummary, errorContent, errorDateTime);
                return insertedValue;
            }
            catch (Exception ex)
            {

                new LogException().Write(string.Format("  Module {0} --Msg {1} ", "ErrorNewsService.WC_Insert", PageId.ToString() + "--------" + ex.Message));
                return 0;
            }
            finally { contextObj.Dispose(); }


        }
        #endregion
        #region IService<New> Members
        public IQueryable<ErrorArticle> GetAll()
        {
            return repository.GetAll();
        }

        public bool Update(ErrorArticle entity)
        {
            throw new NotImplementedException();
        }

        public bool Create(ErrorArticle entity)
        {
            throw new NotImplementedException();
        }

        public bool Delete(ErrorArticle entity)
        {
            throw new NotImplementedException();
        }
         #endregion
    }
}
